package com.the8thfold.anton.ant

import com.the8thfold.anton.settings.Configuration
import com.the8thfold.anton.settings.ConfigurationItem
import grails.plugins.springsecurity.Secured

class SettingsController {

    @Secured(['ROLE_ADMIN'])
    def index = {
        redirect(action: 'list', params:params)
    }

    @Secured(['ROLE_ADMIN'])
    def list = {
        def configs = Configuration.findAll()
        [configs:configs]
    }

    @Secured(['ROLE_ADMIN'])
    def updateProperty = {
        if (params.itemId){
            ConfigurationItem item = ConfigurationItem.findById(params.itemId)
            item.value = params.value
            item.save(flush: true, failOnError: true)
        }
        redirect(action: 'list', params: params)
    }
}
